package org.openstreetmap.josm.plugins.cadastre_es;


public class IsVertex extends Bresenham<Boolean> {
	private int right = 1;
	private int wrong = 0;
	private float pWrong;
	
	
	public IsVertex(Pixel start, Pixel end) {
		super(start, end);
	}

	protected void run(Pixel p) {
		if (p.isFollowed())
			right += 2;
		else if (p.top().isFollowed() || p.bottom().isFollowed() || p.right().isFollowed() || p.left().isFollowed()) {
			right++;
			wrong++;
		}
		else
			wrong++;
	}
	
	public Boolean end() {
		pWrong = ((float)wrong) / ((float)(right + wrong));

        if (pWrong > 0.5)
			return true;
		else
			return false;
	}
	
	public float getPwrong() {
		return pWrong;
	}
}
